'use strict';

/**
 * @ngdoc directive
 * @name jgappApp.directive:deleteFlow
 * @description
 * # deleteFlow
 */
angular.module('jgappApp')
    .directive('deleteFlow', ['Util', '$location', '$rootScope', 'DataService', 'openApi', function(Util, $location, $rootScope, DataService,openApi) {
        return {
            scope: {
                sheetObj: "=sheetData"
            },
            template: '<div class="mt10">' +
                '<div class="btn del" ng-click="showconfirm()">删除</div>' +
                '</div>',
            restrict: 'AE',
            replace: true,
            link: function postLink(scope, element, attrs) {
                scope.showconfirm = function() {
                    $rootScope.showMasker = true;
                    scope.showDailog = true
                    Util.showAuditDailog({
                        scope: scope,
                        title: "删除原因",
                    });
                };
                scope.confirm = function() {
                    scope.showDailog = false;
                    $rootScope.showMasker = false;
                    var param={};
                    param.processInstanceId=attrs.id
                    param.deleteReason =scope.auditText
                    DataService.getData(openApi.deleteprocess,param).then(function(data) {
                        Util.Toast(data,{
                        	callback:Util.goBack
                        })
                    });
                };
                scope.cancel = function() {
                    console.log("cancel")
                    scope.showDailog = false;
                    $rootScope.showMasker = false;
                };


                // element.text('this is the sheetAction directive');
            }
        };
    }]);
